//
//  UIViewController+MBProgressHUDShow.m
//  QNReuseTool
//
//  Created by rsh on 2019/10/15.
//  Copyright © 2019年 rsh. All rights reserved.
//

#import "UIViewController+MBProgressHUDShow.h"

@implementation UIViewController (MBProgressHUDShow)


//用MBProgressHUD自定义的吐丝效果
- (void)hudShowWithString:(NSString *)str delayTime:(CGFloat)time type:(NSInteger)type
{
    if (!str.length) return;
    UIView *view = nil;
    if (type == 1) {
        view = self.view;
    }else{
        view = (UIWindow *)[UIApplication sharedApplication].keyWindow;
    }
    //先移除，再添加
    [MBProgressHUD hideHUDForView:view animated:YES];
    MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:view animated:YES];
    HUD.mode = MBProgressHUDModeCustomView;
    HUD.label.text = str;
    HUD.label.numberOfLines = 0;
    HUD.margin = 13.f;       //margin 边缘留白; opacity 设定透明度;
    //    HUD.offset = CGPointMake(0.f, SCREEN_HEIGHT/2 - 120*SCALE_HEIGHT - SafeAreaBottomHeight);
    [HUD hideAnimated:YES afterDelay:time];
    //*************** 使用旧版的黑色背景白色文字的样式 ***************
    [HUD setContentColor:[UIColor whiteColor]];
    [HUD.bezelView setStyle:MBProgressHUDBackgroundStyleSolidColor];
    [HUD.bezelView setColor:[UIColor colorWithRed:(0)/255.0f green:(0)/255.0f blue:(0)/255.0f alpha:(0.8)]];
    
}


@end
